﻿<UserControl x:Class="TreeGridDemo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=TreeGrid" xmlns:Primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Controls:TreeGridDragDropTarget AllowDrop="True">
            <Controls:TreeGrid x:Name="treeGrid">
                <Controls:TreeGrid.Columns>
                    <Controls:HierarchicalTextColumn x:Name="firstNameColumn" ItemsSource="{Binding Childs}" Width="150" Binding="{Binding FirstName}" CanUserSort="True" AutoExpand="True">
                        <Controls:HierarchicalTextColumn.HeaderStyle>
                            <Style TargetType="Primitives:DataGridColumnHeader">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate>
                                            <StackPanel>
                                                <Primitives:DataGridColumnHeader Content="First Name"/>
                                                <TextBox TextChanged="FirstNameFilterChanged"/>
                                            </StackPanel>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Controls:HierarchicalTextColumn.HeaderStyle>
                    </Controls:HierarchicalTextColumn>
                    <Controls:ManagedTextColumn Width="150" Binding="{Binding LastName}" CanUserSort="True">
                        <Controls:ManagedTextColumn.HeaderStyle>
                            <Style TargetType="Primitives:DataGridColumnHeader">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate>
                                            <StackPanel>
                                                <Primitives:DataGridColumnHeader Content="Last Name"/>
                                                <TextBox TextChanged="LastNameFilterChanged"/>
                                            </StackPanel>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Controls:ManagedTextColumn.HeaderStyle>
                    </Controls:ManagedTextColumn>
                    <Controls:ManagedTextColumn Header="Age" Width="150" Binding="{Binding Age}" CanUserSort="True"/>
                </Controls:TreeGrid.Columns>
            </Controls:TreeGrid>
        </Controls:TreeGridDragDropTarget>
        <StackPanel Grid.Row="1">
            <Button x:Name="addButton" Click="AddClick">
                Add "Mery" to current
            </Button>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Button x:Name="ascButton" Click="AscClick">
                    Sort "First Name" Asc
                </Button>
                <Button x:Name="descButton" Grid.Column="1" Click="DescClick">
                    Sort "First Name" Desc
                </Button>
            </Grid>
        </StackPanel>
    </Grid>
</UserControl>
